package com.guxiaotu.web.controller;

import com.guxiaotu.bean.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Gu Yuanhua
 * created time 2018/9/7 0:01
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    private final Person person;

    @Autowired
    public HelloController(Person person) {
        this.person = person;
    }

    @GetMapping("/{name}")
    public String hello(@PathVariable("name") String name) {
        person.setName (name);
        person.setAge (30);
        return "Hello " + person;
    }
}
